import { _decorator, Component, instantiate, Node, Prefab, tween, UIOpacity } from 'cc';
import { ResourceMgr } from '../../framework/manager/ResourceMgr';
import { ScoreEffect } from '../../components/ScoreEffect';

const { ccclass, property } = _decorator;

@ccclass('ScoreScene')
export class ScoreScene extends Component {

    @property(Prefab)
    private scoreEffectPrefab: Prefab

    private apple: Node

    protected onLoad(): void {
        this.apple = this.node.getChildByPath("Apple")
        ResourceMgr.Instance.addButtonListen(this.node.getChildByName("ShowScoreBtn"), this, this.showScoreEffect)
    }

    private showScoreEffect() {
        let healEffect = instantiate(this.scoreEffectPrefab);
        healEffect.setParent(this.node);
        healEffect.setPosition(this.apple.getPosition());

        let healEffectScript = healEffect.getComponent(ScoreEffect);
        healEffectScript.showScore(1);
    }

}